package com.common.domain.dto;

import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author liuxuhuang
 * @date 2023年05月01日 19:59
 * @desc 新增宿舍财产DTO
 */
@NoArgsConstructor
@AllArgsConstructor
@Setter
@ToString
@Accessors(chain = true)
@EqualsAndHashCode
public class AddDormPropertyDTO {
    /**
     * 宿舍id
     */
    @NotNull(message = "宿舍id不能为空")
    private Long dormId;

    /**
     * 财产名称
     */
    @NotBlank(message = "财产名称不能为空")
    private String propertyName;

    /**
     * 宿舍财产数量
     */
    @NotNull(message = "宿舍财产数量不能为空")
    private Integer propertyNumber;

    public Long getDormId() {
        return dormId;
    }

    public String getPropertyName() {
        return propertyName.replaceAll(" ", "");
    }

    public Integer getPropertyNumber() {
        if (propertyNumber == null || propertyNumber < 0) {
            return 1;
        }
        return propertyNumber;
    }
}
